package cn.iocoder.yudao.hires.mapper;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.hires.entity.NoticeInterviewDO;
import cn.iocoder.yudao.hires.vo.noticeinterview.NoticeInterviewPageReqVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * 下游-面试邀约 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface NoticeInterviewMapper extends BaseMapperX<NoticeInterviewDO> {



    List<NoticeInterviewDO> selectByUserIdAndTenantIdAndDateRange(@Param("userId") Long userId, @Param("tenantId") Long tenantId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);


    default PageResult<NoticeInterviewDO> selectPage(NoticeInterviewPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NoticeInterviewDO>().eqIfPresent(NoticeInterviewDO::getUserId, reqVO.getUserId()).eqIfPresent(NoticeInterviewDO::getPositionId, reqVO.getPositionId()).likeIfPresent(NoticeInterviewDO::getPositionName, reqVO.getPositionName()).betweenIfPresent(NoticeInterviewDO::getInterviewStartTime, reqVO.getInterviewStartTime(), reqVO.getInterviewEndTime()).eqIfPresent(NoticeInterviewDO::getInterviewAddress, reqVO.getInterviewAddress()).eqIfPresent(NoticeInterviewDO::getLongitude, reqVO.getLongitude()).eqIfPresent(NoticeInterviewDO::getLatitude, reqVO.getLatitude()).eqIfPresent(NoticeInterviewDO::getContactPerson, reqVO.getContactPerson()).eqIfPresent(NoticeInterviewDO::getContactPhone, reqVO.getContactPhone()).eqIfPresent(NoticeInterviewDO::getInterviewType, reqVO.getInterviewType()).eqIfPresent(NoticeInterviewDO::getInterviewForm, reqVO.getInterviewForm()).eqIfPresent(NoticeInterviewDO::getStatus, reqVO.getStatus()).eqIfPresent(NoticeInterviewDO::getRemark, reqVO.getRemark()).eqIfPresent(NoticeInterviewDO::getContent, reqVO.getContent()).eqIfPresent(NoticeInterviewDO::getIsRead, reqVO.getIsRead()).betweenIfPresent(NoticeInterviewDO::getCreateTime, reqVO.getCreateTime()).orderByDesc(NoticeInterviewDO::getId));
    }

    /**
     * 获取用户的 面试
     *
     * @param userId
     * @return
     */
    Long getNumberOfInterviews(@Param("userId") Long userId, @Param("tenantId") Long tenantId);


    /**
     * 获取用户的 投递记录
     *
     * @param userId
     * @return
     */
    Long getNumberOfDeliveries(@Param("userId") Long userId, @Param("tenantId") Long tenantId);


    List<NoticeInterviewDO> getNoticeInterviewList(@Param("positionId") Integer positionId,
                                                   @Param("positionName") String positionName, @Param("tenantId") Long tenantId, @Param("userId") Long userId, @Param("status") Long status,@Param("interviewStartTime") String interviewStartTime);

}